<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>json</title>
</head>
<body>
   <div id="message">

   </div>
</body>
<script>

    var person1 = {
         name:'M',  // key-value
         age:13,
         dept:{

         },
         children:[

         ]
    }

    var employees=[
        {
           name:'Zhanng',
           dept:'HR'
        },{
            name:'T',
            dept:'DEV'
        }
    ]

    //document.getElementById('message').innerHTML = employees[1].name;

     // 遍历数组

    // 1. 数组遍历1
    // for(var i=0;i<employees.length;i++){
    //     document.getElementById('message').innerHTML += employees[i].name;
    // }


     /*2. for in --- forech*/  // ctrl + shift +/
    /*for(var key in employees){
       // document.getElementById('message').innerHTML += key;
        document.getElementById('message').innerHTML += employees[key].name;
    }*/

    /*遍历对象*/
    var person2= {
        name:'M',  // key-value
        age:13
    }

    for(var key in person2){
       // alert(key);
        alert(person2[key])
    }


</script>
</html>